package com.xnyzc.lhy.common.penum.order;


/**
 * @Author: wangshuo
 * @Date: 2019-08-07 15:11
 * @Description:
 */
public enum EDiDiOrderStatus {

    waitingResponse(0,100, "等待应答"),
    orderTimeout(1, 111,"订单超时"),
    reassigned(2, 109, "改派中"),
    driverOrder(4, 101,"司机已接单"),
    driverArrived(5, 102,"司机到达"),
    duringTrip(6, 103,"行程中"),
    normalOrderPendingPayment(7,104, "正常订单待支付"),
    cancelPendingPayment(8, 107,"取消行程待支付"),
    cancelOrderNoNeedPayment(10, 106,"取消订单无需支付"),
    paymented(12, 105,"已支付"),
    serviceClose(16, 108,"客服关闭"),
    otherPlatformsAccept(17,110, "该订单已被其他平台受理");


    private Integer type;
    private Integer didiType;
    private String value;

    EDiDiOrderStatus(Integer type, Integer didiType, String value) {
        this.type = type;
        this.didiType = didiType;
        this.value = value;
    }

    public static EDiDiOrderStatus findByDidiType(Integer didiType) {
        for (EDiDiOrderStatus status: EDiDiOrderStatus.values()) {
            if (status.didiType.equals(didiType)) {
                return status;
            }
        }
        throw new IllegalArgumentException("非法type");
    }

    public static EDiDiOrderStatus findById(Integer type) {
        EDiDiOrderStatus diDiOrderStatusMatter;
        switch (type) {
            case 0:
                diDiOrderStatusMatter = EDiDiOrderStatus.waitingResponse;
                break;
            case 1:
                diDiOrderStatusMatter = EDiDiOrderStatus.orderTimeout;
                break;
            case 2:
                diDiOrderStatusMatter = EDiDiOrderStatus.reassigned;
                break;
            case 3:
                diDiOrderStatusMatter = EDiDiOrderStatus.driverOrder;
                break;
            case 5:
                diDiOrderStatusMatter = EDiDiOrderStatus.driverArrived;
                break;
            case 6:
                diDiOrderStatusMatter = EDiDiOrderStatus.duringTrip;
                break;
            case 7:
                diDiOrderStatusMatter = EDiDiOrderStatus.normalOrderPendingPayment;
                break;
            case 9:
                diDiOrderStatusMatter = EDiDiOrderStatus.cancelPendingPayment;
                break;
            case 10:
                diDiOrderStatusMatter = EDiDiOrderStatus.cancelOrderNoNeedPayment;
                break;
            case 12:
                diDiOrderStatusMatter = EDiDiOrderStatus.paymented;
                break;
            case 16:
                diDiOrderStatusMatter = EDiDiOrderStatus.cancelOrderNoNeedPayment;
                break;
            case 17:
                diDiOrderStatusMatter = EDiDiOrderStatus.otherPlatformsAccept;
                break;
            default:
                throw new IllegalArgumentException("非法type");
        }
        return diDiOrderStatusMatter;
    }


    public String getValue() {
        return this.value;
    }

    public Integer getDidiType() {
        return this.didiType;
    }

    public Integer getType() {
        return this.type;
    }

}
